jQuery(document).on("pageinit", "[data-role='page'][data-pagetype='myprodcomments']", function() {
    var page = jQuery(this);
    var _comments_render = this;
    var comments = URL_ACTION_MY_PRODUCTS_COMMENTS;
    var params = {
    };

    var mycomments_listview_render = jQuery.extend(true, {}, listview_render, {
        error_handler: function(){
            var errmsg = page.find("div.errmsg");
            errmsg.find("p").html("您还没有登录！");
            errmsg.popup("open");
        },

        components: {
            page: page,
            ul: page.find("div[data-role='content']").find("ul[data-role='listview']")
        },

        gen_listview_item: function(item){
            return "<li data-itemid='"+item.id+"'>" +
                "<a data-transition='slide' href=" + URL_VIEW_PROD_CONTENT + "?id=" + item.product + ">"+
                "<h2>"+item.nickname+"</h2>"+
                "<p>"+item.content+"</p>" +
                "<p class='ui-li-aside'><strong>" + item.createTime + "</strong></p>" +
                "</a>"+
                "</li>";
        },

        pull_down: function(url, params) {
            var _render = this;
            return listview_render.pull_down.call(_render, url, params).error(function(){
                var ul = _render.components.ul;
                if(ul.jqmData("role") == "listview") {
                    ul.listview("refresh");
                }
            });
        },

        pull_up: function(url, params) {
            var _render = this;
            return listview_render.pull_up.call(_render, url, params).error(function(){
                var ul = _render.components.ul;
                if(ul.jqmData("role") == "listview") {
                    ul.listview("refresh");
                }
            });
        }
    });

    jQuery(".iscroll-wrapper", _comments_render).bind({
        "iscroll_onpulldown" : function(event, data){
            if(mycomments_listview_render.pull_down){
                var params = {
                    offset: mycomments_listview_render.components.ul.children("li:first").jqmData("itemid") || 0,
                    action: "down"
                };
                mycomments_listview_render.pull_down(comments, params);
            }
        },
        "iscroll_onpullup"   :  function(event, data){
            if(mycomments_listview_render.pull_up){
                var params = {
                    offset: mycomments_listview_render.components.ul.children("li:last").jqmData("itemid") || 0,
                    action: "up"
                };
                mycomments_listview_render.pull_up(comments, params);
            }
        }
    });


    mycomments_listview_render.render(comments, params);

});

